home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / ghostscript / 8.64 / Resource / Init / gs_dps1.ps < prev    next >
Encoding:
Text File  |  2009-04-17  |  4.6 KB  |  140 lines

  1. %    Copyright (C) 1997, 1999 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_dps1.ps 8954 2008-08-08 04:22:38Z ray $
  14. % Initialization file for most of the Display PostScript functions
  15. % that are also included in Level 2.
  16.  
  17. level2dict begin
  18.  
  19. % ------ Virtual memory ------ %
  20.  
  21. /currentshared /.currentglobal load def
  22. /scheck /.gcheck load def
  23. %****** FOLLOWING IS WRONG ******
  24. /shareddict currentdict /globaldict .knownget not { 20 dict } if def
  25.  
  26. % Global and LocalFontDirectory must remain in systemdict
  27. % even if we temporarily exit Level 2 mode.
  28.  
  29. end                % level2dict
  30. systemdict begin
  31.  
  32. /SharedFontDirectory .FontDirectory .gcheck
  33.  { .currentglobal false .setglobal
  34.    /LocalFontDirectory .FontDirectory dup maxlength dict copy
  35.    .forcedef    % LocalFontDirectory is local, systemdict is global
  36.    .setglobal .FontDirectory
  37.  }
  38.  { /LocalFontDirectory .FontDirectory
  39.    .forcedef    % LocalFontDirectory is local, systemdict is global
  40.    50 dict
  41.  }
  42. ifelse def
  43.  
  44. end                % systemdict
  45. level2dict begin
  46.  
  47. % setshared must rebind FontDirectory to the appropriate one of
  48. % Local or SharedFontDirectory.
  49.  
  50. /.setglobal        % <bool> .setglobal -
  51.  { dup .setglobal
  52.    //systemdict /FontDirectory .currentglobal
  53.     { //SharedFontDirectory }
  54.     { /LocalFontDirectory .systemvar }    % can't embed ref to local VM
  55.    ifelse .forceput pop    % LocalFontDirectory is local, systemdict is global
  56.  } .bind odef        % must bind .forceput and .setglobal
  57.             % even if NOBIND in effect
  58. % Don't just copy (load) the definition of .setglobal:
  59. % it gets redefined for LL3.
  60. /setshared { /.setglobal .systemvar exec } odef
  61. .currentglobal setshared
  62.  
  63. % See below for changes in save and restore.
  64.  
  65. % ------ Fonts ------ %
  66.  
  67. /selectfont        % <fontname> <size> selectfont -
  68.  {
  69.    { 1 .argindex findfont
  70.      1 index dup type /arraytype eq { makefont } { scalefont } ifelse
  71.      setfont pop pop
  72.    } stopped { /selectfont .systemvar $error /errorname get signalerror } if
  73.  } odef
  74. % undefinefont has to take local/global VM into account.
  75. /undefinefont        % <fontname> undefinefont -
  76.  { .FontDirectory 1 .argindex .forceundef    % FontDirectory is readonly
  77.    .currentglobal
  78.     {        % Current mode is global; delete from local directory too.
  79.       //systemdict /LocalFontDirectory .knownget
  80.        { 1 index .forceundef }        % LocalFontDirectory is readonly
  81.       if
  82.     }
  83.     {        % Current mode is local; if there was a shadowed global
  84.         % definition, copy it into the local directory.
  85.       //systemdict /SharedFontDirectory .knownget
  86.        { 1 index .knownget
  87.       { .FontDirectory 2 index 3 -1 roll { put } //superexec } % readonly
  88.      if
  89.        }
  90.       if
  91.     }
  92.    ifelse pop
  93.  } odef
  94.  
  95. % If we load a font into global VM within an inner save, the restore
  96. % will delete it from FontDirectory but not from SharedFontDirectory.
  97. % We have to handle this by making restore copy missing entries from
  98. % SharedFontDirectory to FontDirectory.  Since this could slow down restore
  99. % considerably, we define a new operator .forcecopynew for this purpose.
  100. % Furthermore, if FAKEFONTS is in effect, we want global real fonts to
  101. % override fake local ones.  We handle this by brute force.
  102. /restore        % <save> restore -
  103.  { dup //restore    % bind even if NOBIND
  104.    /LocalFontDirectory .systemvar
  105.    FAKEFONTS
  106.     { mark
  107.         % We want to delete a fake font from the local directory
  108.         % iff the global directory now has no definition for it,
  109.         % or a non-fake definition.
  110.       1 index dup
  111.        {        % Stack: lfd mark lfd key ... lfd key value
  112.      length 1 gt
  113.       {        % This is a real local definition; don't do anything.
  114.         pop
  115.       }
  116.       {        % This is a fake local definition, check for global.
  117.         //SharedFontDirectory 1 index .knownget
  118.          {        % A global definition exists, check for fake.
  119.            length 1 eq { pop } { 1 index } ifelse
  120.          }
  121.          {        % No global definition, delete the local one.
  122.            1 index
  123.          }
  124.         ifelse
  125.       }
  126.      ifelse
  127.        } forall
  128.       pop counttomark 2 idiv { .forceundef } repeat pop        % readonly
  129.     }
  130.    if
  131.    //SharedFontDirectory exch .forcecopynew pop
  132.    .currentglobal .setglobal    % Rebind FontDirectory according to current VM.
  133.    pop
  134.  } .bind odef
  135.  
  136. end                % level2dict
  137.